/* Team Directories
 *
 * You are free to do whatever you want with this code. Frankly we don't give a damn.
 * 
 *  
 * Copyright GNU General Public License v3
 */



package StudyBuddy;

/**
 * Statistics Class: Gets Scores from all buddies in BuddyCollection and processes them
 * 
 * @version     1.10    27 Feb 2008
 * @author      Rajpreet Bajwa
 */

public class Statistics{
    
    PluginCollection collection;
    
    public Statistics(PluginCollection col){
        
        /** To initilize the statistics class, we have to have a pointer to the plugin
            collection in memory. Therefore the constructor requires such a pointer or
            it renders the class useless**/ 
        collection = col;
        
    }
    
    public int getScore(int index){
        
        /** Get Score gets the score from the plugin Collection **/
        if(index >= 0 && index < collection.getSize()){
            return collection.getPlugin(index).getScore();
        }
        
        return -1;
    }
    
    public int getAverage(){
        
        int sum = 0;
        
        for (int i = 0; i < collection.getSize(); i++){
            
            sum = sum + collection.getPlugin(i).getScore();
            
        }
        
        return sum/collection.getSize();
        
    }
    
}
